package com.libui.utils

import android.graphics.Color

class ColorUtils {
    companion object {
        fun toHexString(color: Int): String {
            return String.format("#%06X", 0xFFFFFF and color)
        }

        fun toColor(colorString: String): Int {
            var str = colorString
            if (colorString.startsWith("0x")) {
                str = colorString.replace("0x", "#")
            } else if (!colorString.startsWith("#")) {
                str = "#$colorString"
            }

            return Color.parseColor(str)
        }
    }
}